
//
//  LeeBaoChouZuiGaoRenWuViewController.m
//  firstpoint
//
//  Created by 李雪虎 on 2017/7/27.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "LeeBaoChouZuiGaoRenWuViewController.h"
#import "XiTongRenWuTableViewCell.h"
@interface LeeBaoChouZuiGaoRenWuViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView *tabelView;
@property(nonatomic,strong)NSMutableArray *bigArr;
@property(nonatomic,assign)int page;
@end

@implementation LeeBaoChouZuiGaoRenWuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"报酬最高任务";
    _page =0;
    _bigArr = [NSMutableArray array];
    [self httpUrlRuqestRewu];
    self.view.backgroundColor = [UIColor whiteColor];
    _tabelView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, width_screen, height_screen-64) style:UITableViewStyleGrouped];
    _tabelView.backgroundColor = [UIColor clearColor];
    _tabelView.showsVerticalScrollIndicator = NO;//隐藏滑动条
    _tabelView.separatorColor = COLOR(229, 230, 231, 1);//分割线颜色
    _tabelView.delegate = self;
    _tabelView.dataSource = self;
    [_tabelView registerClass:[XiTongRenWuTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_tabelView];
    
    MJRefreshAutoGifFooter*footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadData)];
    [HTTPURL MJfoodDH:footer];
    _tabelView.mj_footer = footer;
    // Do any additional setup after loading the view.
}
-(void)loadData{
    _page++;
    [self httpUrlRuqestRewu];
}
//区头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
//cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 100;
}
//返回多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _bigArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    XiTongRenWuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (_bigArr.count>0) {
        cell.titleLab.text = [NSString stringWithFormat:@"%@",_bigArr[indexPath.row][@"title"]];//b标题
        cell.jindouLab.text = [NSString stringWithFormat:@"%@ 金豆",_bigArr[indexPath.row][@"everyoneAmount"]];//金豆
        if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==5) {
            [cell.button setTitle:@"系统分享任务" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==6){
            [cell.button setTitle:@"新手上传头像" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==7){
            [cell.button setTitle:@"新手完善资料" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==8){
            [cell.button setTitle:@"系统任务列表" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==9){
            [cell.button setTitle:@"系统邀请好友" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==10){
            [cell.button setTitle:@"系统购买商品" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==11){
            [cell.button setTitle:@"新手任务列表" forState:UIControlStateNormal];
        }else if ([_bigArr[indexPath.row][@"taskTypeId"]intValue]==12){
            [cell.button setTitle:@"新手邀请好友" forState:UIControlStateNormal];
        }
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.navigationController popToRootViewControllerAnimated:YES];
}
-(void)httpUrlRuqestRewu{
    NSLog(@"%@",CIT_number);
    NSString *nub = [NSString stringWithFormat:@"%@",CIT_number];
    NSString *url = [NSString stringWithFormat:@"%@%@",LINK_BASE_URL(@"task/sortByAvgAmount.api?access_token="),NSUD_Obj(@"token")];
    __weak typeof(self) waekSelf =self;
        [HTTPURL postRequest:url parameters:@{@"pageIndex":@(_page),@"areaId":nub} success:^(NSURLSessionDataTask *task, id responseObject) {
            if ([responseObject[@"retFlag"]integerValue]==1) {
        NSDictionary *dic = [PublicTools dictionaryWithJsonString:responseObject[@"data"]];
        NSArray *array = [NSArray array];
        array = dic[@"rows"];
        [_bigArr addObjectsFromArray:array];
        [waekSelf.tabelView reloadData];
            }
//        [waekSelf.tabelView.mj_footer endRefreshing];
    } filure:^(NSURLSessionDataTask *task, id error) {
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
